package cn.tedu.bonfire.front.account.controller;

import cn.tedu.bonfire.common.web.JsonResult;
import cn.tedu.bonfire.front.account.pojo.param.UserRegisterParam;
import cn.tedu.bonfire.front.account.service.IUserRegisterService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/users")
@Validated
@Api(tags = "1. 用户注册")
public class UserRegisterController {

    @Autowired
    IUserRegisterService userRegisterService;

    @PostMapping("/register")
    @ApiOperation("用户注册")
    @ApiOperationSupport(order = 100)
    public JsonResult register(@Validated UserRegisterParam userRegisterParam) {
        userRegisterService.register(userRegisterParam);
        return JsonResult.ok();
    }

    @PostMapping("/captcha/phone")
    @ApiOperation("获取注册手机号验证码")
    @ApiOperationSupport(order = 120)
    public JsonResult getPhoneCaptcha(String phone) {
        log.debug("开始处理【获取登录手机号验证码】的请求，参数：{}", phone);
        userRegisterService.getCaptchaByPhone(phone);
        return JsonResult.ok();
    }


}
